Imports System.Collections

Partial Class pages_settings_usercontrols_UCSetting : Inherits UserControl

#Region "Members"
    Private m_setting As SchemaMikeConnellMinistries.CSetting
    Private m_sortedList As IList
#End Region

#Region "Interface"
    Public Sub Display(ByVal [setting] As SchemaMikeConnellMinistries.CSetting, sortedList As IList)
        If Parent.Controls.Count Mod 2 = 0 Then row.Attributes.Add("class", "alt_row")

        m_setting = [setting]
        m_sortedList = sortedList
        colOrder.Visible = sortedList.Count > 1
        btnDelete.Visible = CSession.IsDeveloper

        With m_setting
            litSettingId.Text = 1 + sortedList.IndexOf(m_setting) '.SettingId.ToString()
            lnkSettingName.Text = CStr(IIf(.SettingName.Length = 0, "...", .SettingName))
            lnkSettingName.NavigateUrl = CSitemap.SettingEdit(.SettingId)
            lnkSettingValue.Text = .Value
            lnkSettingValue.NavigateUrl = CSitemap.SettingValue(.SettingId)
            litType.Text = .TypeId.ToString
        End With
    End Sub
#End Region

#Region "Event Handlers"
    Private Sub btnMoveUp_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnMoveUp.Click
        With New CSettingList(m_sortedList)
            .MoveUp(m_setting)
        End With
        Refresh()
    End Sub
    Private Sub btnMoveDn_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnMoveDn.Click
        With New CSettingList(m_sortedList)
            .MoveDown(m_setting)
        End With
        Refresh()
    End Sub
    Private Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnDelete.Click
        m_setting.Delete()
        Refresh()
    End Sub
#End Region

#Region "Private"
    Private Sub Refresh()
        'CCache.ClearCache()

        'If False Then 'Request.RawUrl.ToLower.Contains("myparent.aspx") Then
        '    'Special case: Parent entity owns the list
        '    Response.Redirect(CSitemap.MyParentEdit(m_setting.SettingParentId, MyParent.ETab.settings, m_pageIndex)
        'Else
        '    'Normal case: Search page owns the list
            Response.Redirect(Request.RawUrl) 'includes paging info
        'End If 
    End Sub
#End Region

End Class
